package nc.impl.yst;

import nc.bs.dao.BaseDAO;
import nc.bs.dao.DAOException;
import nc.itf.yst.BLJHSqlService;
import nc.vo.pub.lang.UFDateTime;
import nc.vo.yst.bljh.BljhHVO;

public class BLJHSqlServiceImpl implements BLJHSqlService {

	@Override
	public int saveSign(BljhHVO hvo) throws DAOException {
		BaseDAO dao = new BaseDAO();
		StringBuffer sql = new StringBuffer();
		sql.append("update yst_bljh_h set fstatusflag = ");
		sql.append(hvo.getAttributeValue("fstatusflag"));
		sql.append(" ,signor='");
		sql.append(hvo.getAttributeValue("signor"));
		sql.append("',signdate='");
		sql.append(hvo.getAttributeValue("signdate"));
		sql.append("',dr=");
		sql.append(hvo.getDr());
		sql.append("  where dr=0 and pk_head = '");
		sql.append(hvo.getPrimaryKey());
		sql.append("';");
		
		
		return dao.executeUpdate(sql.toString());
	}

	@Override
	public int saveCSign(BljhHVO hvo) throws DAOException {
		BaseDAO dao = new BaseDAO();
		StringBuffer sql = new StringBuffer();
		sql.append("update yst_bljh_h set fstatusflag = ");
		sql.append(hvo.getAttributeValue("fstatusflag"));
		sql.append(" ,signor=null,signdate=null,dr=0");
		sql.append("  where dr=0 and pk_head = '");
		sql.append(hvo.getPrimaryKey());
		sql.append("';");
		
		
		return dao.executeUpdate(sql.toString());
	}

	@Override
	public int updateistodown(BljhHVO hvo) throws DAOException
	{
		
		BaseDAO dao = new BaseDAO();
		StringBuffer sql = new StringBuffer();
		sql.append("update yst_bljh_h set istodown = ");
		sql.append(" 'Y' ");
		sql.append("  where dr=0 and pk_head = '");
		sql.append(hvo.getPrimaryKey());
		sql.append("';");
		
		
		return dao.executeUpdate(sql.toString());
	}

	@Override
	public int updateIsToRc(String pk_head) throws DAOException
	{ 
		BaseDAO dao = new BaseDAO();
		StringBuffer sql = new StringBuffer();
		sql.append("update yst_bljh_h set istorc = ");
		sql.append(" 'Y' ");
		sql.append("  where dr=0 and pk_head = '");
		sql.append(pk_head);
		sql.append("';");
		
		
		return dao.executeUpdate(sql.toString());
	}

	@Override
	public int updateIsToCc(String pk_head) throws DAOException
	{
		BaseDAO dao = new BaseDAO();
		StringBuffer sql = new StringBuffer();
		sql.append("update yst_bljh_h set istocc = ");
		sql.append(" 'Y' ");
		sql.append("  where dr=0 and pk_head = '");
		sql.append(pk_head);
		sql.append("';");
		
		
		return dao.executeUpdate(sql.toString());
	}

	public int updateDownbills(String pk_head)throws DAOException
	{
		BaseDAO dao = new BaseDAO();
		StringBuffer sql = new StringBuffer();
		sql.append("update yst_bljh_h set istodown = 'N', istorc='N', istocc='N', istoscbg='N' ");
		sql.append("  where dr=0 and pk_head = '");
		sql.append(pk_head);
		sql.append("';");
		
		
		return dao.executeUpdate(sql.toString());

	}
}
